/*
This file is part of Docking@Home.
http://docking.gcl.cis.udel.edu
Copyright (C) 2009 University of Delaware

Docking@Home is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Docking@Home is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Docking@Home.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
	Filename: Atom.cpp
	Description: Represents an atoms with specific properties that are needed 
		for this simulation and rendering. This file contains all of the implementation
		of functions that are listed in the header file.
	Revision History: 
		Created - 11/06/07
		Made more Object Oriented - 01/04/08
	Author: Robert Keller (11/06/07 - Current)
*/

#include "Atom.h"
#include <string>

// ------------------------------------------------------------
// Constructor / Destructor
// ------------------------------------------------------------

Atom::Atom()
{
	id = 0;
	mass = 0.0f;

	x_coor = 0.0f;
	y_coor = 0.0f;
	z_coor = 0.0f;
}

Atom::~Atom()
{
}

// ------------------------------------------------------------
// Member Modifiers
// ------------------------------------------------------------

void Atom::setId (int i)
{
	id = i;
}// setId

void Atom::setName (char n [5] )
{
	memcpy(name, n, sizeof(char) * 5);
}// setName

void Atom::setMass (float m)
{
	mass = m;
}// setMass

void Atom::setXCoord (float x)
{
	x_coor = x;
} // setXCoord

void Atom::setYCoord (float y)
{
	y_coor = y;
} // setXCoord

void Atom::setZCoord (float z)
{
	z_coor = z;
} // setZCoord

// function that assigns a color based on atom name
// Used JMOL Color Scheme: see http://jmol.sourceforge.net/jscolors/
void Atom::setColorID()
{
	char name [5];
	getName(name);

	if (name[0] == ' ')
	{
		switch (name[1])
		{
		case 'C':	
			colorID = CYAN_ID;
			break;

		case 'H':	colorID = WHITE_ID;
					setMass(5);
					break;
		case 'N':	colorID = BLUE_ID;
					break;
		case 'O':	colorID = RED_ID;
					break;
		case 'S':	colorID = YELLOW_ID;
					break;
		case 'P':	colorID = TAN_ID;
					break;
		case 'Z':	colorID = SILVER_ID;
					break;
		default: 
			colorID = WHITE_ID;
			break;
		}// switch
	}// if
	else
	{
		switch(name[0])
		{
		case 'C':
			if (name[1] == 'A')
				colorID = ORANGE_ID;
			break;
		case 'H':
			if (name[1] == 'G')
				colorID = GRAY_ID;
			break;
		case 'O':
			if (name[1] == 'S')
				colorID = WHITE_ID; // Just a filler for now
			// Oxygen but has other properties immediately after it
			else
				colorID = RED_ID;	
			break;
		default:
			colorID = WHITE_ID;
			break;
		}// switch
	}// else
}// setColorID

// ------------------------------------------------------------
// Member Accessors
// ------------------------------------------------------------

int Atom::getId () const
{
	return id;
}// getId

void Atom::getName (char n[5]) const
{
	memcpy(n, name, sizeof(char) * 5);
}// getName

float Atom::getMass () const
{
	return mass;
}// getMass

float Atom::getXCoord () const
{
	return x_coor;
}// getXCoord

float Atom::getYCoord () const
{
	return y_coor;
}// getYCoord

float Atom::getZCoord () const
{
	return z_coor;
}// getZCoord

int Atom::getColorID () const
{
	return colorID;
}// getColorID
